package cn.itcast.service.impl;

import cn.itcast.dao.UserDao;
import cn.itcast.domain.User;
import cn.itcast.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
  @Autowired
  private UserDao userDao;

  public User loginUser(String phone, String password) {
    User user = userDao.findByPhone(phone);
    if (user != null && user.getPassword().equals(password)) {
      return user;
    }
    return null;
  }
  public User checkLogin(String phone){
    User user = userDao.findByPhone(phone);
    if (user != null){
      return user;
    }
    return null;
  }

  public void RegisterUser(User user){
    userDao.RegisterUser(user);
  }
  public User findRegister(String phone) {
    return userDao.findByPhone(phone);
  }

  public User findUpdUser(String phone){
    return userDao.findByPhone(phone);
  }
  public void updUser(User user){
    userDao.updateUser(user);
  }
}
